package ai.basic;

import java.util.Random;

import hexgame.GameLogic;
import hexgame.GameState;
import hexgame.HexMove;
import hexgame.HexPlayer;
import hexgame.Player;

public class RandomAIPlayer extends Player {
	GameState state;
	public RandomAIPlayer(GameState state) {
		this.state = state;
	}
	
	@Override
	public boolean isConnected() {
		return true;
	}

	@Override
	public HexMove getMove() {
		HexMove move = new HexMove(this.randInt(), this.randInt(), HexPlayer.RED_LOCAL);
		
		while(!GameLogic.isValidMove(state, move)) {
			move = new HexMove(this.randInt(), this.randInt(), HexPlayer.RED_LOCAL);
		}
		
		return move;
	}

	@Override
	public void showMove(HexMove move) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void gameOver(boolean didWin) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendErrorMessage(String message) {
		// TODO Auto-generated method stub
		
	}
	
	public int randInt() {
		Random rand = new Random();
		
		return rand.nextInt(state.getBoardSize() + 1);
	}

}
